package com.baosight.risk.web.api;

import com.alibaba.fastjson.JSON;
import com.baosight.risk.api.api.HuaBaoService;
import com.baosight.risk.api.zbaa.IZbaaTargetService;
import com.baosight.risk.base.controller.BaseController;
import com.baosight.risk.common.result.AjaxResult;
import com.baosight.risk.service.zbaa.vo.ZbaaTargetHomeIndexVO;
import com.baosight.risk.service.zbaa.vo.ZbaaTargetValueVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.Resources;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 侯湘锦
 * @create 2020/09/21 13:29
 */
@Slf4j
@RestController
@RequestMapping("/fkapi/huabao")
@Api(value = "华宝接口", description = "华宝获取数据接口", produces = MediaType.APPLICATION_JSON)
public class HuaBaoApiController extends BaseController {

    @Resource
    private IZbaaTargetService targetService;
    @Resource
    private HuaBaoService huaBaoService;

    @GetMapping("daily/data")
    @ApiOperation("获取每日数据")
    public AjaxResult  getDailyData(){

       Map<String,Object> dataMap=new HashMap<String,Object>(3);

        List<ZbaaTargetHomeIndexVO> data = huaBaoService.getHomeIndex();

        Object status = huaBaoService.getHomeIndexStatus();
        if (status == null) {
            JSON.toJSONString(error());
        }
        dataMap.put("status",status);

        List<List<ZbaaTargetValueVO>> dataList = huaBaoService.getHomeIndexDataList();

        dataMap.put("data",data);
        dataMap.put("dataList",dataList);
        return success(dataMap);
    }






}
